<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Admin\Controller;


/**
 * 后台首页控制器
 * 主要获取首页聚合数据
 */
class ProductguanliController extends AdminController {
    
	//产品管理
	public function product_guanli(){
        //$map = array();
        //$map  = array('status' => 1);
        //if(isset($_GET['name'])){
         //   $map['name']    =   array('like', '%'.(string)I('name').'%');
        //}
		
		$lists = $this->lists('Product_info',$map,'id asc');
		//$lists  = D('Customer_info')->where($map)->order('uid asc')->select();//查询语句
    	$this->assign('productguanli',$lists);
	 
	    $this->display();
	}

	//产品编辑
	public function product_bianji($customer_choose='',$name='',$classification='',$introduction=''){
		if(isset($_POST['submit'])){
			$product_info=array('customer_choose'=>$customer_choose,'name'=>$name,'classification'=>$classification,'introduction'=>$introduction);
			if(!M('Product_info')->add($product_info)){
				echo "<script>alert('产品添加失败！');</script>";
            }else{
                echo "<script>alert('产品添加成功！');</script>";

            }
		
		}
        
		
	    $this->display();
	}
	//产品添加
	public function product_tianjia($customer_choose='',$name='',$classification='',$introduction=''){
		if(isset($_POST['submit'])){
			$product_info=array('customer_choose'=>$customer_choose,'name'=>$name,'classification'=>$classification,'introduction'=>$introduction);
			if(!M('Product_info')->add($product_info)){
				echo "<script>alert('产品添加失败！');</script>";
            }else{
                echo "<script>alert('产品添加成功！');</script>";

            }
		
		}

	    $this->display();
	}

	//标注内容
	public function biaozhu_content(){
	    $this->display();
	
	}
    
	//标注管理
	public function biaozhu_guanli(){
	    $this->display();
	
	}

	//删除操作
	public function del(){
		$id=array_unique((array)I('id',0));
		if(empty($id)){
			$this->error('请输入数据!');

		}
		$where=array('id'=>array('in',$id));
		if(M('Product_info')->where($where)->delete()){
			S('DB_CONFIG_DATA',null);
			//记录行为
			action_log('update_config','Product_info',$id,UID);
			$this->success('删除成功');
		}else{
			$this->error('删除失败');
		}
	}

	//屏蔽，显示代码
	public function changestatus($method=null){
		$id=array_unique((array)I('id',0));
		$id=is_array($id) ? implode(',',$id) : $id;
		//var_dump($id);exit;
		if(empty($id)){
			$this->error('请选择要操作的数据');

		}
		$where['id']=array('in',$id);
		switch(strtolower($method)){
			case 'forbidproduct':
				$this->forbid('Product_info',$where);
				break;
			case 'resumeproduct':
				$this->resume('Product_info',$where);
				break;
			default:
				$this->error('参数非法');

		}

	}

}




?>